var express = require('express');
var router = express.Router();
var db = require("../sqlcon");
/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('sys_login');
});
router.get('/sys_index', function(req, res, next) {
    res.render('sys_index');
});
router.post("/login",function(req,res,next){
    var userName = req.body.username;
    var pwd = req.body.password;
    var sql = "select * from loginuser where userName=? and pwd=?";
    db.query(sql,[userName,pwd],function(err,data){
        if(err){
            res.send("数据库操作异常");
        }
        else if(data.length > 0){
            res.render("sys_index",{userName: userName});
        }
        else{
            res.send("用户名或密码不正确");
        }
    })
})

module.exports = router;
